import Base64 from '@/lib/base64.min'

/**
 * 微信用户信息对象
 */
export default {
  encode: function (wxInfoVO) {
    if (!wxInfoVO) return null
    try {
      if (wxInfoVO.NickName) {
        wxInfoVO.NickName = Base64.encode(wxInfoVO.NickName)
      }
    } catch (error) {
      window.console.log('base64 encode error: wxInfoVO.NickName')
    }
    return wxInfoVO
  },
  decode: function (wxInfoVO) {
    if (!wxInfoVO) return null
    try {
      if (wxInfoVO.NickName) {
        wxInfoVO.NickName = Base64.decode(wxInfoVO.NickName)
      }
    } catch (error) {
      window.console.log('base64 decode error: wxInfoVO.NickName')
    }
    return wxInfoVO
  }
}
